package com.example.springdemo.service;

import com.example.springdemo.entity.User;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Wenyi Luo
 * @ClassName UserService
 * @Description TODO
 * @date 22/3/6 16:28
 * @version: 1.0
 */
@Service
public class UserService implements IUserService {
    @Resource
    UserRepository userRepository;


    @Override
    public List<User> findAll() {
        return (List<User>) userRepository.findAll();
    }

    @Override
    public User save(User user) {
        return userRepository.save(user);
    }

    @Override
    public List<User> findAllByPaging(PageRequest pageRequest) {
        return (List<User>) userRepository.findAll(pageRequest);
    }

    @Override
    public List<User> findByName(String name){
        return null;
    }

    @Override
    public User findOnlyUser(String name, int age) {
        return userRepository.findDistinctByNameAndAgeGreaterThan(name,age);
    }



    /**
     * 根据用户ID，查询用户信息
     *
     * @param userId
     */
    @Override
    public User findById(int userId) {
        return null;
    }

    /**
     * 修改用户
     *
     * @param user
     */
    @Override
    public User edit(User user) {
        return null;
    }

    /**
     * 删除用户
     *
     * @param userId
     */
    @Override
    public boolean deleteById(int userId) {
        return false;
    }

}
